﻿using System.IO;
using Com.Lancetinc.Evs.Helpers;

namespace Com.Lancetinc.Evs.Config;

public abstract class AbsConfig : IAppConfig
{
    /// <inheritdoc />
    public abstract string ConfigPath { get; }

    protected string GetConfigRoot(bool withLang)
    {
        var configRoot = Path.Combine(DirUtil.ExeDirectory, "Config");
        if (withLang)
        {
            configRoot = Path.Combine(configRoot, I18nHelper.Default.Lang);
        }

        DirUtil.EnsureDirectoryExists(configRoot);
        return configRoot;
    }

    protected string GetConfigFile(string fileName, bool withLang)
    {
        return Path.Combine(GetConfigRoot(withLang), fileName);
    }
}